package big.conn;

import java.sql.Connection;
import java.sql.SQLException;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;

public class DbcpBean {
	private Connection conn;
	private DataSource ds;
	public DbcpBean(){
		try{
			Context initContext = new InitialContext();
			Context envContext  = 
							(Context)initContext.lookup("java:/comp/env");
			ds = (DataSource)envContext.lookup("jdbc/xe");
		}catch(NamingException ne){
			System.err.println(ne.getMessage());
		}
	}
	public Connection getConn() throws SQLException{
		conn = ds.getConnection();
		return conn;
	}
}
